package org.bird.natives;

public class Hello {

	public static void main(String[] args) {
		 System.out.println("---------basic type test---------");  
		  System.out.println(""+5+"+"+8+"="+sum(5,8));  
		   
		  System.out.println("---------String type test---------");  
		  if(args.length == 0){  
		   System.out.println("input the data");  
		   return;  
		  }  
		  String newString = addHeaderString(args[0]);  
		   
		  System.out.println(newString);  
		  System.out.println("length="+newString.length());  
		   
		  System.out.println("---------Array type test---------");  
		  int[] data = new int[10];  
		  System.out.println("primitive data is:");  
		  for(int ii=0;ii<data.length;ii++){  
		   data[ii] = ii;  
		   System.out.print(data[ii]+" ");  
		  }  
		  System.out.println();  
		  System.out.println("improved data is:");  
		  int[] result = improve(data,data.length);  
		  for(int ii=0;ii<result.length;ii++){  
		   System.out.print(result[ii]+",");  
		  }  
		  System.out.println();  
		  System.out.println("primitive data is:");  
		  for(int ii=0;ii<data.length;ii++){  
		   data[ii] = ii;  
		   System.out.print(data[ii]+" ");  
		  }  
	}
	
	 private static native String addHeaderString(String str);  
	 private static native int sum(int a,int b);  
	 private static native int[] improve(int[] data,int size);  
	 static{  
	  System.loadLibrary("Hello");  
	  /*when classload load the class input jvm,it will load the methods of Hello.dll into native method of jvm; 
	    this way suppport the input with absolute path.such as xx/xx/Hello.dll; 
	  */  
	 }  
}
